<?php

class Core_Backend_Component_Global_View_Area_Index extends Core_Backend_Share_View_Grid {

    public function __construct() {
        parent::__construct();
    }

    protected function buildNavigation($navigation) {
        $navigation->addLabel($this->__f('global.title.area_index'));
        parent::buildNavigation($navigation);
    }

    protected function buildToolbar($toolbar){
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
        $group->addLink($this->getUrl(NULL, 'create'), $this->__('share.button.create'));
    }

    protected function buildGrid($grid) {
        $grid->setId('area_grid')->setPrimaryKey('id');
        $grid->addLabelColumn($this->__('share.label.code'), 'code', '{code}')
                ->setWidth(200);
        $grid->addLabelColumn($this->__('share.label.name'), 'name', '{name}')
                ->setWidth(200);
        $grid->addLabelColumn($this->__('share.label.domainName'), 'domain_name', '{domain_name}')
                ->setWidth(200);
        $grid->addLabelColumn($this->__('share.label.url'), 'url', '{url}');
        $grid->addLabelColumn($this->__('share.label.default'), 'is_default', '{is_default}')
                ->setWidth(200);
        $grid->addLinkColumn('#', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        parent::buildPagination($pagination);
        $pagination->setUrlFormat($this->getPaginationUrl())
                ->setRecordCount($this->getRecords());
    }
}